<template>
	<view style="background-color: rgba(0, 0, 0, 0.3);">
		<video class='item' :src="list[0].video" v-if='show' autoplay></video>
		<swiper class="swiper" circular v-else>
			<swiper-item v-for="(item,index) in list" :key="index">
				<view class="item masking" v-if="item.type=='video'" @click='show=true'>
					<u-icon name="play-circle" color='#fff' size='80rpx'></u-icon>
					<view class="duration">
						{{convertSecondsToMinutes(list[0].duration)}}
					</view>
				</view>
				<image class='item' :src="item.url" mode="aspectFit"></image>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		props: ['list'],
		data() {
			return {
				show: false
			}
		},
		methods: {
			convertSecondsToMinutes(seconds) {
				var minutes = Math.floor(seconds / 60);
				var remainingSeconds = seconds % 60;

				var minutesString = minutes.toString();
				var secondsString = remainingSeconds.toString();

				if (minutes < 10) {
					minutesString = "0" + minutesString;
				}

				if (remainingSeconds < 10) {
					secondsString = "0" + secondsString;
				}

				return minutesString + ":" + secondsString;
			}
		}
	}
</script>

<style lang="scss" scoped>
	.swiper {

		height: 462rpx;
	}

	.item {
		width: 100%;
		height: 462rpx;
	}

	.masking {
		position: absolute;
		top: 0;
		left: 0;
		// background-color: rgba(0, 0, 0, 0.3);
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.duration {
		color: #fff;
		background-color: rgba(0, 0, 0, 0.5);
		position: absolute;
		bottom: 10rpx;
		right: 20rpx;
		padding: 5rpx 10rpx;
		border-radius: 8rpx;
	}
</style>